package com.xidata.dict.client.embedded.service;

import com.xidata.dict.client.embedded.model.CodeDictItem;
import com.xidata.dict.client.embedded.model.CodeDictTreeItem;

import java.util.Collection;

public interface CodeDictTranslator {

    void translate(String codeType, CodeDictItem item);

    default void translate(String codeType, Collection<? extends CodeDictItem> items) {
        for (CodeDictItem item : items) {
            translate(codeType, item);
        }
    }

    default void translateTree(String codeType, CodeDictTreeItem root) {
        translate(codeType, root);
        if (root.getChildren() != null) {
            for (CodeDictTreeItem item : root.getChildren()) {
                translateTree(codeType, item);
            }
        }
    }
}
